package com.yiqi.zhiyuan.feature.mine.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.yiqi.zhiyuan.entity.vo.CarVO;
import com.yiqi.zhiyuan.feature.mine.contract.CarContract;
import com.yiqi.zhiyuan.feature.mine.dependencies.register.DaggerCarModelComponent;
import com.yiqi.zhiyuan.framework.api.ApiLib;
import com.yiqi.zhiyuan.framework.api.CarApi;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @ProjectName: ZhiYuan
 * @Description: 注册model
 * @Author: lijuwen
 * @CreateDate: 2019/3/13 13:07
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/13 13:07
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class CarModel implements CarContract.Model {
    @Inject
    CarApi api;

    public CarModel() {
        DaggerCarModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<List<CarVO>> doGetDiverCarList() {
        return api.selectDriverCarList().compose(RxDataProcessFactory.<List<CarVO>>dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> doDeleteCarInDriver(String ids) {
        return api.deleteCarInDriver(ids).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> doOrderQuickSetup(Integer driverId) {
        return api.orderQuickSetup(driverId).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}

